use crate::src::src::compare_string::{string_compare, string_nocase_compare, string_equal, string_nocase_equal};
use crate::src::test::framework::{run_tests};
use crate::src::src::compare_int::{int_compare, int_equal};
use crate::src::src::compare_pointer::{pointer_compare, pointer_equal};
use crate::src::struct_and_type::{UnitTestFunction};
use ::libc;
extern "C" {
    
    
    
    
    
    
    
    
    
}
#[no_mangle]
pub unsafe extern "C" fn test_int_compare() {
    let mut a: libc::c_int = 4 as libc::c_int;
    let mut b: libc::c_int = 8 as libc::c_int;
    let mut c: libc::c_int = 4 as libc::c_int;
    assert!(int_compare(
        &mut a as *mut libc::c_int as *mut libc::c_void,
        &mut b as *mut libc::c_int as *mut libc::c_void,
    ) < 0 as libc::c_int);
    assert!(int_compare(
        &mut b as *mut libc::c_int as *mut libc::c_void,
        &mut a as *mut libc::c_int as *mut libc::c_void,
    ) > 0 as libc::c_int);
    assert!(int_compare(
        &mut a as *mut libc::c_int as *mut libc::c_void,
        &mut c as *mut libc::c_int as *mut libc::c_void,
    ) == 0 as libc::c_int);
}
#[no_mangle]
pub unsafe extern "C" fn test_int_equal() {
    let mut a: libc::c_int = 4 as libc::c_int;
    let mut b: libc::c_int = 8 as libc::c_int;
    let mut c: libc::c_int = 4 as libc::c_int;
    assert!(int_equal(
        &mut a as *mut libc::c_int as *mut libc::c_void,
        &mut c as *mut libc::c_int as *mut libc::c_void,
    ) != 0 as libc::c_int);
    assert!(int_equal(
        &mut a as *mut libc::c_int as *mut libc::c_void,
        &mut b as *mut libc::c_int as *mut libc::c_void,
    ) == 0 as libc::c_int);
}
#[no_mangle]
pub unsafe extern "C" fn test_pointer_compare() {
    let mut array: [libc::c_int; 5] = [0; 5];
    assert!(pointer_compare(
        &mut *array.as_mut_ptr().offset(0 as libc::c_int as isize) as *mut libc::c_int
            as *mut libc::c_void,
        &mut *array.as_mut_ptr().offset(4 as libc::c_int as isize) as *mut libc::c_int
            as *mut libc::c_void,
    ) < 0 as libc::c_int);
    assert!(pointer_compare(
        &mut *array.as_mut_ptr().offset(3 as libc::c_int as isize) as *mut libc::c_int
            as *mut libc::c_void,
        &mut *array.as_mut_ptr().offset(2 as libc::c_int as isize) as *mut libc::c_int
            as *mut libc::c_void,
    ) > 0 as libc::c_int);
    assert!(pointer_compare(
        &mut *array.as_mut_ptr().offset(4 as libc::c_int as isize) as *mut libc::c_int
            as *mut libc::c_void,
        &mut *array.as_mut_ptr().offset(4 as libc::c_int as isize) as *mut libc::c_int
            as *mut libc::c_void,
    ) == 0 as libc::c_int);
}
#[no_mangle]
pub unsafe extern "C" fn test_pointer_equal() {
    let mut a: libc::c_int = 0;
    let mut b: libc::c_int = 0;
    assert!(pointer_equal(
        &mut a as *mut libc::c_int as *mut libc::c_void,
        &mut a as *mut libc::c_int as *mut libc::c_void,
    ) != 0 as libc::c_int);
    assert!(pointer_equal(
        &mut a as *mut libc::c_int as *mut libc::c_void,
        &mut b as *mut libc::c_int as *mut libc::c_void,
    ) == 0 as libc::c_int);
}
#[no_mangle]
pub unsafe extern "C" fn test_string_compare() {
    let mut test1: [libc::c_char; 6] = *::core::mem::transmute::<
        &[u8; 6],
        &mut [libc::c_char; 6],
    >(b"Apple\0");
    let mut test2: [libc::c_char; 7] = *::core::mem::transmute::<
        &[u8; 7],
        &mut [libc::c_char; 7],
    >(b"Orange\0");
    let mut test3: [libc::c_char; 6] = *::core::mem::transmute::<
        &[u8; 6],
        &mut [libc::c_char; 6],
    >(b"Apple\0");
    assert!(string_compare(
        test1.as_mut_ptr() as *mut libc::c_void,
        test2.as_mut_ptr() as *mut libc::c_void,
    ) < 0 as libc::c_int);
    assert!(string_compare(
        test2.as_mut_ptr() as *mut libc::c_void,
        test1.as_mut_ptr() as *mut libc::c_void,
    ) > 0 as libc::c_int);
    assert!(string_compare(
        test1.as_mut_ptr() as *mut libc::c_void,
        test3.as_mut_ptr() as *mut libc::c_void,
    ) == 0 as libc::c_int);
}
#[no_mangle]
pub unsafe extern "C" fn test_string_equal() {
    let mut test1: [libc::c_char; 22] = *::core::mem::transmute::<
        &[u8; 22],
        &mut [libc::c_char; 22],
    >(b"this is a test string\0");
    let mut test2: [libc::c_char; 23] = *::core::mem::transmute::<
        &[u8; 23],
        &mut [libc::c_char; 23],
    >(b"this is a test string \0");
    let mut test3: [libc::c_char; 21] = *::core::mem::transmute::<
        &[u8; 21],
        &mut [libc::c_char; 21],
    >(b"this is a test strin\0");
    let mut test4: [libc::c_char; 22] = *::core::mem::transmute::<
        &[u8; 22],
        &mut [libc::c_char; 22],
    >(b"this is a test strinG\0");
    let mut test5: [libc::c_char; 22] = *::core::mem::transmute::<
        &[u8; 22],
        &mut [libc::c_char; 22],
    >(b"this is a test string\0");
    assert!(string_equal(
        test1.as_mut_ptr() as *mut libc::c_void,
        test5.as_mut_ptr() as *mut libc::c_void,
    ) != 0 as libc::c_int);
    assert!(string_equal(
        test1.as_mut_ptr() as *mut libc::c_void,
        test2.as_mut_ptr() as *mut libc::c_void,
    ) == 0 as libc::c_int);
    assert!(string_equal(
        test1.as_mut_ptr() as *mut libc::c_void,
        test3.as_mut_ptr() as *mut libc::c_void,
    ) == 0 as libc::c_int);
    assert!(string_equal(
        test1.as_mut_ptr() as *mut libc::c_void,
        test4.as_mut_ptr() as *mut libc::c_void,
    ) == 0 as libc::c_int);
}
#[no_mangle]
pub unsafe extern "C" fn test_string_nocase_compare() {
    let mut test1: [libc::c_char; 6] = *::core::mem::transmute::<
        &[u8; 6],
        &mut [libc::c_char; 6],
    >(b"Apple\0");
    let mut test2: [libc::c_char; 7] = *::core::mem::transmute::<
        &[u8; 7],
        &mut [libc::c_char; 7],
    >(b"Orange\0");
    let mut test3: [libc::c_char; 6] = *::core::mem::transmute::<
        &[u8; 6],
        &mut [libc::c_char; 6],
    >(b"Apple\0");
    let mut test4: [libc::c_char; 6] = *::core::mem::transmute::<
        &[u8; 6],
        &mut [libc::c_char; 6],
    >(b"Alpha\0");
    let mut test5: [libc::c_char; 6] = *::core::mem::transmute::<
        &[u8; 6],
        &mut [libc::c_char; 6],
    >(b"bravo\0");
    let mut test6: [libc::c_char; 8] = *::core::mem::transmute::<
        &[u8; 8],
        &mut [libc::c_char; 8],
    >(b"Charlie\0");
    assert!(string_nocase_compare(
        test1.as_mut_ptr() as *mut libc::c_void,
        test2.as_mut_ptr() as *mut libc::c_void,
    ) < 0 as libc::c_int);
    assert!(string_nocase_compare(
        test2.as_mut_ptr() as *mut libc::c_void,
        test1.as_mut_ptr() as *mut libc::c_void,
    ) > 0 as libc::c_int);
    assert!(string_nocase_compare(
        test1.as_mut_ptr() as *mut libc::c_void,
        test3.as_mut_ptr() as *mut libc::c_void,
    ) == 0 as libc::c_int);
    assert!(string_nocase_compare(
        test4.as_mut_ptr() as *mut libc::c_void,
        test5.as_mut_ptr() as *mut libc::c_void,
    ) < 0 as libc::c_int);
    assert!(string_nocase_compare(
        test5.as_mut_ptr() as *mut libc::c_void,
        test6.as_mut_ptr() as *mut libc::c_void,
    ) < 0 as libc::c_int);
}
#[no_mangle]
pub unsafe extern "C" fn test_string_nocase_equal() {
    let mut test1: [libc::c_char; 22] = *::core::mem::transmute::<
        &[u8; 22],
        &mut [libc::c_char; 22],
    >(b"this is a test string\0");
    let mut test2: [libc::c_char; 23] = *::core::mem::transmute::<
        &[u8; 23],
        &mut [libc::c_char; 23],
    >(b"this is a test string \0");
    let mut test3: [libc::c_char; 21] = *::core::mem::transmute::<
        &[u8; 21],
        &mut [libc::c_char; 21],
    >(b"this is a test strin\0");
    let mut test4: [libc::c_char; 22] = *::core::mem::transmute::<
        &[u8; 22],
        &mut [libc::c_char; 22],
    >(b"this is a test strinG\0");
    let mut test5: [libc::c_char; 22] = *::core::mem::transmute::<
        &[u8; 22],
        &mut [libc::c_char; 22],
    >(b"this is a test string\0");
    assert!(string_nocase_equal(
        test1.as_mut_ptr() as *mut libc::c_void,
        test5.as_mut_ptr() as *mut libc::c_void,
    ) != 0 as libc::c_int);
    assert!(string_nocase_equal(
        test1.as_mut_ptr() as *mut libc::c_void,
        test2.as_mut_ptr() as *mut libc::c_void,
    ) == 0 as libc::c_int);
    assert!(string_nocase_equal(
        test1.as_mut_ptr() as *mut libc::c_void,
        test3.as_mut_ptr() as *mut libc::c_void,
    ) == 0 as libc::c_int);
    assert!(string_nocase_equal(
        test1.as_mut_ptr() as *mut libc::c_void,
        test4.as_mut_ptr() as *mut libc::c_void,
    ) != 0 as libc::c_int);
}
static mut tests_test_compare_functions: [UnitTestFunction; 9] = unsafe {
    [
        Some(test_int_compare as unsafe extern "C" fn() -> ()),
        Some(test_int_equal as unsafe extern "C" fn() -> ()),
        Some(test_pointer_compare as unsafe extern "C" fn() -> ()),
        Some(test_pointer_equal as unsafe extern "C" fn() -> ()),
        Some(test_string_compare as unsafe extern "C" fn() -> ()),
        Some(test_string_equal as unsafe extern "C" fn() -> ()),
        Some(test_string_nocase_compare as unsafe extern "C" fn() -> ()),
        Some(test_string_nocase_equal as unsafe extern "C" fn() -> ()),
        None,
    ]
};
unsafe fn main_0_test_compare_functions(
    mut argc: libc::c_int,
    mut argv: *mut *mut libc::c_char,
) -> libc::c_int {
    run_tests(tests_test_compare_functions.as_mut_ptr());
    return 0 as libc::c_int;
}
pub fn main_test_compare_functions() {
    let mut args: Vec::<*mut libc::c_char> = Vec::new();
    for arg in ::std::env::args() {
        args.push(
            (::std::ffi::CString::new(arg))
                .expect("Failed to convert argument into CString.")
                .into_raw(),
        );
    }
    args.push(::core::ptr::null_mut());
    unsafe {
        ::std::process::exit(
            main_0_test_compare_functions(
                (args.len() - 1) as libc::c_int,
                args.as_mut_ptr() as *mut *mut libc::c_char,
            ) as i32,
        )
    }
}
